package mylogger1


type Logger struct {
	level logLevel
}


func NewLogger(levelstr string) Logger {
	level, err := parseloglevel(levelstr)
	if err != nil{
		panic(err)
	}
	return Logger{
		level: level,
	}
}


func (l Logger)enable(loglevel logLevel) bool {
	return l.level <= loglevel
}

func (l Logger)Debug(format string, a ...interface{})  {
	if l.enable(DEBUG) {
	log(DEBUG,format,a...)
	}
}

func (l Logger)Trace(format string, a ...interface{})  {
	if l.enable(TRACE) {
		log(TRACE,format,a...)
	}
}

func (l Logger)Info(format string, a ...interface{}) {
	if l.enable(INFO) {
		log(INFO,format,a...)
	}
}
func (l Logger)Warning(format string, a ...interface{})  {
	if l.enable(WARNING) {
		log(WARNING,format,a...)
	}
}

func (l Logger)Error(format string, a ...interface{}) {
	if l.enable(ERROR) {
		log(ERROR,format,a...)
	}
}
func (l Logger)Fatal(format string, a ...interface{}) {
	if l.enable(FATAL) {
		log(FATAL,format,a...)
	}

}